package com.api;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.SocketException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/* access modifiers changed from: package-private */
public final class UDPClient {
    private ExecutorService A;
    private DatagramSocket w;

    public interface UDPListener {
        void onIOException();

        void onMessage(String str);

        void onTimeout();
    }

    private UDPClient() {
        this.w = null;
        this.A = Executors.newCachedThreadPool();
        try {
            this.w = new DatagramSocket();
            this.w.setBroadcast(true);
        } catch (SocketException e) {
            e.printStackTrace();
            this.w = null;
        }
    }

    /* synthetic */ UDPClient(byte b) {
        this();
    }

    public final void a(byte[] bArr, InetAddress inetAddress, int i) {
        DatagramPacket datagramPacket = new DatagramPacket(bArr, bArr.length, inetAddress, i);
        try {
            if (this.w != null) {
                this.w.send(datagramPacket);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
